<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>fdk-aac: Encoder Behaviour</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">fdk-aac
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Encoder Behaviour </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="BEHAVIOUR_BANDWIDTH"></a>
Bandwidth</h1>
<p>The FDK AAC encoder usually does not use the full frequency range of the input signal, but restricts the bandwidth according to certain library-internal settings. They can be changed in the table "bandWidthTable" in the file bandwidth.cpp (if available).</p>
<p>The encoder API provides the ::AACENC_BANDWIDTH parameter to adjust the bandwidth explicitly.</p><div class="fragment"><div class="line"> aacEncoder_SetParam(hAacEncoder, AACENC_BANDWIDTH,</div>
<div class="line">value); </div>
</div><!-- fragment --><p>However it is not recommended to change these settings, because they are based on numerous listening tests and careful tweaks to ensure the best overall encoding quality. Also, the maximum bandwidth that can be set manually by the user is 20kHz or fs/2, whichever value is smaller.</p>
<p>Theoretically a signal of for example 48 kHz can contain frequencies up to 24 kHz, but to use this full range in an audio encoder usually does not make sense. Usually the encoder has a very limited amount of bits to spend (typically 128 kbit/s for stereo 48 kHz content) and to allow full range bandwidth would waste a lot of these bits for frequencies the human ear is hardly able to perceive anyway, if at all. Hence it is wise to use the available bits for the really important frequency range and just skip the rest. At lower bitrates (e. g. &lt;= 80 kbit/s for stereo 48 kHz content) the encoder will choose an even smaller bandwidth, because an encoded signal with smaller bandwidth and hence less artifacts sounds better than a signal with higher bandwidth but then more coding artefacts across all frequencies. These artefacts would occur if small bitrates and high bandwidths are chosen because the available bits are just not enough to encode all frequencies well.</p>
<p>Unfortunately some people evaluate encoding quality based on possible bandwidth as well, but it is a double-edged sword considering the trade-off described above.</p>
<p>Another aspect is workload consumption. The higher the allowed bandwidth, the more frequency lines have to be processed, which in turn increases the workload.</p>
<h1><a class="anchor" id="FRAMESIZES_AND_BIT_RESERVOIR"></a>
Frame Sizes &amp; Bit Reservoir</h1>
<p>For AAC there is a difference between constant bit rate and constant frame length due to the so-called bit reservoir technique, which allows the encoder to use less bits in an AAC frame for those audio signal sections which are easy to encode, and then spend them at a later point in time for more complex audio sections. The extent to which this "bit exchange" is done is limited to allow for reliable and relatively low delay real time streaming. Therefore, for AAC-ELD, the bitreservoir is limited. It varies between 500 and 4000 bits/frame, depending on the bitrate/channel.</p><ul>
<li>For a bitrate of 12kbps/channel and below, the AAC-ELD bitreservoir is 500 bits/frame.</li>
<li>For a bitrate of 70kbps/channel and above, the AAC-ELD bitreservoir is 4000 bits/frame.</li>
<li>Between 12kbps/channel and 70kbps/channel, the AAC-ELD bitrervoir is increased linearly.</li>
<li>For AAC-LC, the bitrate is only limited by the maximum AAC frame length. It is, regardless of the available bit reservoir, defined as 6144 bits per channel.</li>
</ul>
<p>Over a longer period in time the bitrate will be constant in the AAC constant bitrate mode, e.g. for ISDN transmission. This means that in AAC each bitstream frame will in general have a different length in bytes but over time it will reach the target bitrate.</p>
<p>One could also make an MPEG compliant AAC encoder which always produces constant length packages for each AAC frame, but the audio quality would be considerably worse since the bit reservoir technique would have to be switched off completely. A higher bit rate would have to be used to get the same audio quality as with an enabled bit reservoir.</p>
<p>For mp3 by the way, the same bit reservoir technique exists, but there each bit stream frame has a constant length for a given bit rate (ignoring the padding byte). In mp3 there is a so-called "back pointer" which tells the decoder which bits belong to the current mp3 frame - and in general some or many bits have been transmitted in an earlier mp3 frame. Basically this leads to the same "bit exchange between mp3 frames" as in AAC but with virtually constant length frames.</p>
<p>This variable frame length at "constant bit rate" is not something special in this Fraunhofer IIS AAC encoder. AAC has been designed in that way.</p>
<h2><a class="anchor" id="BEHAVIOUR_ESTIM_AVG_FRAMESIZES"></a>
Estimating Average Frame Sizes</h2>
<p>A HE-AAC v1 or v2 audio frame contains 2048 PCM samples per channel.</p>
<p>The number of HE-AAC frames <img class="formulaInl" alt="$N\_FRAMES$" src="form_2.png"/> per second at 44.1 kHz is:</p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ N\_FRAMES = 44100 / 2048 = 21.5332 \]" src="form_3.png"/>
</p>
<p>At a bit rate of 8 kbps the average number of bits per frame <img class="formulaInl" alt="$N\_BITS\_PER\_FRAME$" src="form_4.png"/> is:</p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ N\_BITS\_PER\_FRAME = 8000 / 21.5332 = 371.52 \]" src="form_5.png"/>
</p>
<p>which is about 46.44 bytes per encoded frame.</p>
<p>At a bit rate of 32 kbps, which is quite high for single channel HE-AAC v1, it is:</p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ N\_BITS\_PER\_FRAME = 32000 / 21.5332 = 1486 \]" src="form_6.png"/>
</p>
<p>which is about 185.76 bytes per encoded frame.</p>
<p>These bits/frame figures are average figures where each AAC frame generally has a different size in bytes. To calculate the same for AAC-LC just use 1024 instead of 2048 PCM samples per frame and channel. For AAC-LD/ELD it is either 480 or 512 PCM samples per frame and channel.</p>
<h1><a class="anchor" id="BEHAVIOUR_TOOLS"></a>
Encoder Tools</h1>
<p>The AAC encoder supports TNS, PNS, MS, Intensity and activates these tools depending on the audio signal and the encoder configuration (i.e. bitrate or AOT). It is not required to configure these tools manually.</p>
<p>PNS improves encoding quality only for certain bitrates. Therefore it makes sense to activate PNS only for these bitrates and save the processing power required for PNS (about 10 % of the encoder) when using other bitrates. This is done automatically inside the encoder library. PNS is disabled inside the encoder library if an MPEG-2 AOT is choosen since PNS is an MPEG-4 AAC feature.</p>
<p>If SBR is activated, the encoder automatically deactivates PNS internally. If TNS is disabled but PNS is allowed, the encoder deactivates PNS calculation internally. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
